package com.visualize.demo.controller;

import com.visualize.demo.model.JsonResponse;
import com.visualize.demo.service.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ShowController {

    private final FiveEmotionService fiveEmotionService;
    private final ThreeEmotionService threeEmotionService;
    private final SourceService sourceService;
    private final PlaceService placeService;
    private final RefreshRateService refreshRateService;


    public ShowController(FiveEmotionService fiveEmotionService, ThreeEmotionService threeEmotionService, SourceService sourceService, PlaceService placeService, RefreshRateService refreshRateService) {
        this.fiveEmotionService = fiveEmotionService;
        this.threeEmotionService = threeEmotionService;
        this.sourceService = sourceService;
        this.placeService = placeService;
        this.refreshRateService = refreshRateService;
    }

    //======================== 原始数据 ========================\\

    @ResponseBody
    @GetMapping("api/five_emotion")
    public JsonResponse ShowFiveEmotion(String sTime, String eTime) {
        return fiveEmotionService.getData(sTime, eTime);
    }

    @ResponseBody
    @GetMapping("api/three_emotion")
    public JsonResponse ShowThreeEmotion(String sTime, String eTime) {
        return threeEmotionService.getData(sTime, eTime);
    }

    @ResponseBody
    @GetMapping("api/source")
    public JsonResponse ShowSource(String sTime, String eTime) {
        return sourceService.getData(sTime, eTime);
    }

    @ResponseBody
    @GetMapping("api/place")
    public JsonResponse ShowPlace(String sTime, String eTime) {
        return placeService.getData(sTime, eTime);
    }

    @ResponseBody
    @GetMapping("api/refresh_rate")
    public JsonResponse ShowRefreshRate(String sTime, String eTime) {
        return refreshRateService.getData(sTime, eTime);
    }


    //======================== 百分比数据 ========================\\

    @ResponseBody
    @GetMapping("api/five_emotion_percent")
    public JsonResponse ShowFiveEmotionPercent(String sTime, String eTime) {
        return fiveEmotionService.getPercentData(sTime, eTime);
    }

    @ResponseBody
    @GetMapping("api/three_emotion_percent")
    public JsonResponse ShowThreeEmotionPercent(String sTime, String eTime) {
        return threeEmotionService.getPercentData(sTime, eTime);
    }


}
